home *** CD-ROM | disk | FTP | other *** search
/ Visual Cafe 3 / Visual Cafe 3.ISO / Vcafe / JFC.bin / TableModel.java < prev    next >
Text File  |  1998-06-30  |  5KB  |  137 lines

  1. /*
  2.  * @(#)TableModel.java    1.12 98/01/30
  3.  *
  4.  * Copyright (c) 1997 Sun Microsystems, Inc. All Rights Reserved.
  5.  *
  6.  * This software is the confidential and proprietary information of Sun
  7.  * Microsystems, Inc. ("Confidential Information").  You shall not
  8.  * disclose such Confidential Information and shall use it only in
  9.  * accordance with the terms of the license agreement you entered into
  10.  * with Sun.
  11.  *
  12.  * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
  13.  * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  14.  * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
  15.  * PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES
  16.  * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
  17.  * THIS SOFTWARE OR ITS DERIVATIVES.
  18.  *
  19.  */
  20.  
  21. package com.sun.java.swing.table;
  22.  
  23. import com.sun.java.swing.*;
  24. import com.sun.java.swing.event.*;
  25.  
  26. /**
  27.  *  The <B>TableModel</B> interface ispecifies the methods the JTable 
  28.  *  will use to interrogate a tabular data model. <p>
  29.  *
  30.  *  The JTable can be set up to display any data model which implements the 
  31.  *  TableModel interface with a couple of lines of code:  <p>
  32.  *  <code>
  33.  *  TableModel myData = new MyTableModel(); 
  34.  *  JTable table = new JTable(myData);
  35.  *  </code><p>
  36.  *
  37.  * @version 1.12 01/30/98
  38.  * @author Philip Milne
  39.  * @author Alan Chung
  40.  * @see JTable
  41.  * @see AbstractTableModel
  42.  */
  43.  
  44. public interface TableModel
  45. {
  46.     /**
  47.      * Returns the number of records managed by the data source object. A
  48.      * <B>JTable</B> uses this method to determine how many rows it
  49.      * should create and display.  This method should be quick, as it
  50.      * is call by <B>JTable</B> quite frequently.
  51.      *
  52.      * @return the number or rows in the model
  53.      * @see #getColumnCount()
  54.      */
  55.     public int getRowCount();
  56.  
  57.     /**
  58.      * Returns the number of columns managed by the data source object. A
  59.      * <B>JTable</B> uses this method to determine how many columns it
  60.      * should create and display on initialization.
  61.      *
  62.      * @return the number or columns in the model
  63.      * @see #getRowCount()
  64.      */
  65.     public int getColumnCount();
  66.  
  67.     /**
  68.      * Returns the name of the column at <i>columnIndex</i>.  This is used
  69.      * to initialize the table's column header name.  Note, this name does
  70.      * not need to be unique.  Two columns on a table can have the same name.
  71.      *
  72.      * @param    columnIndex    the index of column
  73.      * @return  the name of the column
  74.      */
  75.     public String getColumnName(int columnIndex);
  76.  
  77.     /**
  78.      * Returns the lowest common denominator Class in the column.  This is used
  79.      * by the table to set up a default renderer and editor for the column.
  80.      *
  81.      * @return the common ancestor class of the object values in the model.
  82.      */
  83.     public Class getColumnClass(int columnIndex);
  84.  
  85.     /**
  86.      * Returns true if the cell at <I>rowIndex</I> and <I>columnIndex</I>
  87.      * is editable.  Otherwise, setValueAt() on the cell will not change
  88.      * the value of that cell.
  89.      *
  90.      * @param    rowIndex    the row whose value is to be looked up
  91.      * @param    columnIndex    the column whose value is to be looked up
  92.      * @return    true if the cell is editable.
  93.      * @see #setValueAt()
  94.      */
  95.     public boolean isCellEditable(int rowIndex, int columnIndex);
  96.  
  97.     /**
  98.      * Returns an attribute value for the cell at <I>columnIndex</I>
  99.      * and <I>rowIndex</I>.
  100.      *
  101.      * @param    rowIndex    the row whose value is to be looked up
  102.      * @param    columnIndex     the column whose value is to be looked up
  103.      * @return    the value Object at the specified cell
  104.      */
  105.     public Object getValueAt(int rowIndex, int columnIndex);
  106.  
  107.     /**
  108.      * Sets an attribute value for the record in the cell at
  109.      * <I>columnIndex</I> and <I>rowIndex</I>.  <I>aValue</I> is
  110.      * the new value.
  111.      *
  112.      * @param    aValue         the new value
  113.      * @param    rowIndex     the row whose value is to be changed
  114.      * @param    columnIndex      the column whose value is to be changed
  115.      * @see #getValueAt()
  116.      * @see #isCellEditable()
  117.      */
  118.     public void setValueAt(Object aValue, int rowIndex, int columnIndex);
  119.  
  120.     /**
  121.      * Add a listener to the list that's notified each time a change
  122.      * to the data model occurs.
  123.      *
  124.      * @param    l        the TableModelListener
  125.      */
  126.     public void addTableModelListener(TableModelListener l);
  127.  
  128.     /**
  129.      * Remove a listener from the list that's notified each time a
  130.      * change to the data model occurs.
  131.      *
  132.      * @param    l        the TableModelListener
  133.      */
  134.     public void removeTableModelListener(TableModelListener l);
  135. }
  136.  
  137.